[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>[#assign module]class/${item.scope.id}/attributes[/#assign][#assign moduleName="属性"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]</title>
<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery.select.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<script type="text/javascript">
var refClassId = ${(item.refClass.id)!0};
var showDynaClassesFlag = false; 
function showDynaClasses(showFlag){
    if(!showFlag){
        $("#selectDynaClasses").hide();
        return;
    }
    if(!showDynaClassesFlag){
        $("#selectDynaClasses").createSelect("${base}/project/${(item.scope.scope.id)!0}/classes/list", 
        	    {}, function(row){
        	        return [row.id, row.cell[1]];
        	    }, refClassId);
        showDynaClassesFlag = true;
    }
    $("#selectDynaClasses").show();
}
$(function(){
    var options = [[0,"字符串"],[1,"整型"],[2,"长整型"],[3,"单精度浮点型"],[4,"双精度浮点型"],[5,"布尔型"],[6,"日期型"],[7,"时间型"],[8,"日期时间"],[9,"动态类"],[10,"系统类会务"],[11,"系统类分组"],[12,"系统类用户"]];
    var attrType = ${(item.type)!0};
    $("#selectType").createSelect(options, attrType).change(function(){
        var selectedValue = $(this).val();
        showDynaClasses(selectedValue==9);
    });
    showDynaClasses(attrType==9&&refClassId>0);
	
	$("#btadditem").bind("click", function(){
		$("#additemform").ajaxForm({
			dataType: "json",
			success: function(json){
				if(!json.success){
					art.dialog.through({
						title: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败",
						icon: "error",
						content: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败！<br>"+json.err,
						width: 250,
						height: 150,
						background: '#EEE', // 背景色
						opacity: 0.05,	// 透明度
						lock: true,
						ok: true
					});
				}else{
					try{
						art.dialog.top.frames["_iframe"].window.flexGridReload(".flexme3");
					}catch(e){
					   try{
					       art.dialog.open.origin.flexGridReload(".flexme3");
					   }catch(e){
					       art.dialog.top.window.flexGridReload(".flexme3");
					   }
					}
					art.dialog.close();
				}
			}
		});
	});
});
</script>
</head>
<body>
<h3>[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]</h3>
<form id="additemform" action="${base}/${module}/${((item.id)??)?string('edit','add')}" method="POST">
<input type="hidden" name="id" value=${(item.id)!0}>
${moduleName}名:<input type="text" name="name" value="${(item.name)!}"/><br>
属性名:<input type="text" name="attributeName" value="${(item.attributeName)!}"/><br>
描述:<textarea rows="3" cols="35" name="description">${(item.description)!}</textarea><br>
类型：<select id="selectType" name="type"></select>
<select name="refClass.id" id="selectDynaClasses" style="width: 150px">
    <option value="0">--请选择动态类--</option>
</select><br>
长度:<input type="text" name="size" value="${(item.size)!0}"><br>
格式:<input type="text" name="format" value="${(item.format)!}"><br>
<input type="checkbox" name="nullable" id="db_nullable" value="true"[#if !(item??)||(item.nullable)] checked[/#if]><label for="db_nullable">可以为空</label><br>
<input type="checkbox" name="eternal" id="cb_eternal" value="true"[#if (item.eternal)??&&item.eternal] checked[/#if]><label for="cb_eternal">恒久数据（一次性创建，不能更新）</label><br>
<input type="checkbox" name="subList" id="cb_isList" value="true"[#if (item.subList)??&&item.subList] checked[/#if]><label for="cb_isList">列表属性</label><br>
<input type="checkbox" name="carrier" id="cb_carrier" value="true"[#if (item.carrier)??&&item.carrier] checked[/#if]><label for="cb_carrier">附属载体（不需要持久化到数据库）</label><br>

<input type="submit" value="[#if (item.id)??]保存${moduleName}信息[#else]保存新${moduleName}[/#if]" id="btadditem">
</form>
</body>
</html>